function calculateWorkTime(config, startTime, endTime) {
  // 2025-06-26 14:30 2025-06-27 13:30
  console.log('当前配置信息', config, startTime, endTime);

  // Parse configuration
  const workTime = config
    .find((item) => item.confKey === 'work_time')
    .confValue.split('-');
  const restTime = config
    .find((item) => item.confKey === 'rest_time')
    .confValue.split('-');
  const workDays = config
    .find((item) => item.confKey === 'work_day')
    .confValue.split(',')
    .map(Number);

  const startDate = new Date(startTime);
  const endDate = new Date(endTime);

  const workStartHour = parseInt(workTime[0].split(':')[0]);
  const workStartMinute = parseInt(workTime[0].split(':')[1]);
  const workEndHour = parseInt(workTime[1].split(':')[0]);
  const workEndMinute = parseInt(workTime[1].split(':')[1]);

  const restStartHour = parseInt(restTime[0].split(':')[0]);
  const restStartMinute = parseInt(restTime[0].split(':')[1]);
  const restEndHour = parseInt(restTime[1].split(':')[0]);
  const restEndMinute = parseInt(restTime[1].split(':')[1]);

  let totalWorkMinutes = 0;

  // Helper function to calculate overlap in minutes
  function calculateOverlap(start1, end1, start2, end2) {
    const overlapStart = Math.max(start1, start2);
    const overlapEnd = Math.min(end1, end2);
    return Math.max(0, (overlapEnd - overlapStart) / (1000 * 60));
  }

  // Iterate through each day in the range
  for (
    let date = new Date(startDate);
    date <= endDate;
    date.setDate(date.getDate() + 1)
  ) {
    const dayOfWeek = date.getDay() === 0 ? 7 : date.getDay(); // Adjust Sunday to 7
    if (!workDays.includes(dayOfWeek)) {
      continue; // Skip non-workdays
    }

    // Define work start and end times for the current day
    const workStartTime = new Date(date);
    workStartTime.setHours(workStartHour, workStartMinute, 0, 0);
    const workEndTime = new Date(date);
    workEndTime.setHours(workEndHour, workEndMinute, 0, 0);

    // Define rest start and end times for the current day
    const restStartTime = new Date(date);
    restStartTime.setHours(restStartHour, restStartMinute, 0, 0);
    const restEndTime = new Date(date);
    restEndTime.setHours(restEndHour, restEndMinute, 0, 0);

    // Calculate overlap with the specified range
    const dailyStart =
      date.toDateString() === startDate.toDateString()
        ? startDate
        : workStartTime;
    const dailyEnd =
      date.toDateString() === endDate.toDateString() ? endDate : workEndTime;

    // 计算实际工作区间与工作时间的重叠
    const workMinutes = calculateOverlap(
      dailyStart,
      dailyEnd,
      workStartTime,
      workEndTime
    );

    // 只在实际工作区间内扣除午休的重叠部分
    let restMinutes = 0;
    if (workMinutes > 0) {
      const actualWorkStart = new Date(Math.max(dailyStart, workStartTime));
      const actualWorkEnd = new Date(Math.min(dailyEnd, workEndTime));
      restMinutes = calculateOverlap(
        actualWorkStart,
        actualWorkEnd,
        restStartTime,
        restEndTime
      );
    }

    // Add effective work minutes for the day
    totalWorkMinutes += Math.max(0, workMinutes - restMinutes);
  }

  // Convert total minutes to hours and minutes
  const hours = Math.floor(totalWorkMinutes / 60);
  const minutes = totalWorkMinutes % 60;

  return { hours, minutes };
} 